package login;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-30
 * Time: 12:46
 */
public class Test {
    public static void login() {
        User user = new User();
        System.out.println("欢迎来到登录页面！");
        System.out.println("请输入您的用户名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入您的密码：");
        String password = scanner.nextLine();
        try {
            if (!name.equals(user.getName())) {
                throw new UserNameException("用户名错误！");
            }
            if (!password.equals(user.getPassword())) {
                throw new UserPasswordException("密码错误！");
            }
        }catch (UserNameException e) {
            e.printStackTrace();
            return;
        } catch (UserPasswordException e) {
            e.printStackTrace();
            return;
        }
        if(name.equals(user.getName()) && password.equals(user.getPassword())) {
            System.out.println("登陆成功！");
        }
    }

    public static void main(String[] args) {
        login();
    }
}
